package com.lhd.controller;

import com.lhd.pojo.Img;
import com.lhd.pojo.Result;
import com.lhd.service.ImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/img")
public class ImgController {
    @Autowired
    ImgService imgService;
    @GetMapping("/all")
    public Result getAll(){
        List<Img> imgList = imgService.getAll();
        return Result.success(imgList);
    }
    @PutMapping
    public Result update(@RequestBody Img img){
        imgService.update(img);
        return Result.success();
    }
    @PostMapping
    public Result add(String url){
        imgService.add(url);
        return Result.success();
    }
    @DeleteMapping
    public Result remove(Integer id){
        imgService.remove(id);
        return Result.success();
    }
}
